package bookstore_mall.exception;

import bookstore_mall.resp.ResultCodeEnum;
import lombok.Data;

/**
 * 业务异常
 *
 * @author 张三丰
 * @date 2023/12/02
 */
@Data
public class BusinessException extends RuntimeException{
    private Integer code;
    private String message;

    private Object data;

    public BusinessException(String message, Integer code) {
        super(message);
        this.code = code;
        this.data=new Object();
    }
    public BusinessException(String message) {
        super(message);
    }
    public BusinessException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
        this.message = resultCodeEnum.getMessage();
        this.data=new Object();
    }
    public BusinessException(ResultCodeEnum resultCodeEnum,String message)
    {
        this.code = resultCodeEnum.getCode();
        this.message=message;
        this.data=new Object();
    }

    public BusinessException(ResultCodeEnum resultCodeEnum, Object data,String message)
    {
        this.code = resultCodeEnum.getCode();
        this.message=message;
        this.data=data;
    }
}
